package cn.touna.jss.common.filter;

import cn.touna.jss.common.filter.entity.WrappedHttpServletRequest;
import org.springframework.core.annotation.Order;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * \* User: MeiZhongHao
 * \* Date: 2018-06-08
 * \* Time: 16:49
 * \* Description:
 * \
 */
@Order(1)
@WebFilter(filterName = "HttpServletRequestWrapperFilter", urlPatterns = "/crs/applyCredit")
public class HttpServletRequestWrapperFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
            throws IOException, ServletException {
        WrappedHttpServletRequest requestWrapper = new WrappedHttpServletRequest((HttpServletRequest)servletRequest);
        filterChain.doFilter(requestWrapper,servletResponse);
    }

    @Override
    public void destroy() {
    }
}